package com.starinside.wp.foundation.constant;

import lombok.Setter;

import java.util.Arrays;
import java.util.List;

/**
 * @author diao.qiao@outlook.com
 * @version V1.0
 * @description:
 * @since 2019-01-29
 */
public class RecommendCourseConstant {


    public enum AbilityLevel {
        WEAK(0, 85),
        NORMAL(85, 115),
        GOOD(115, 130),
        BEST(130, 1000),;

        @Setter
        private Integer min;
        @Setter
        private Integer max;

        AbilityLevel(Integer min, Integer max) {
            this.min = min;
            this.max = max;
        }

        public Integer minOf() {
            return min;
        }

        public Integer maxOf() {
            return max;
        }
    }


    public enum OptionType {
        BIG_BODY_ACTION(1, "", "大肢体动作", "大肢体运动"),
        CAREFUL_ACTION(2, "", "精细动作", "精细动作"),
        ATTENTION(3, "A", "注意力", "注意力"),
        ACKNOWLEDGE_PROGRESS(4, "T", "认知发展", "逻辑思维能力,记忆力"),
        LANGUAGE_PROGRESS(5, "", "语言发展", "语言表达"),
        EMOTION(6, "S", "情感与社会性", "社会交往能力"),
        SELF(7, "", "自理能力", "自我服务,自我学习"),;

        @Setter
        private int code;

        @Setter
        private String type;

        @Setter
        private String value;
        @Setter
        private String topic;

        OptionType(int code, String type, String value, String topic) {
            this.code = code;
            this.type = type;
            this.value = value;
            this.topic = topic;
        }

        public int codeOf() {
            return code;
        }

        public String valueOf() {
            return value;
        }

        public String typeOf() {
            return type;
        }

        public OptionType get(int code) {
            for (OptionType type : values()) {
                if (type.codeOf() == code)
                    return type;
            }
            return null;
        }

        public static List<String> getTopicByValue(String value) {
            for (OptionType type : values()) {
                if (type.value.equals(value))
                    return Arrays.asList(type.topic.split(","));
            }
            return null;
        }

        public static String getValueByTopic(List<String> topics) {
            for (OptionType type : values()) {
                for (String topic : topics) {
                    if (type.topic.contains(topic))
                        return type.valueOf();
                    if (topic.equals(ATTENTION.type))
                        return ATTENTION.valueOf();
                    if (topic.equals(ACKNOWLEDGE_PROGRESS.type))
                        return ACKNOWLEDGE_PROGRESS.valueOf();
                    if (topic.equals(EMOTION.type))
                        return EMOTION.valueOf();
                }
            }
            return null;
        }
    }
}
